package controllers.sensors.implementation.tinkerforge;

import java.util.ArrayList;

import models.SensorType;
import models.SensorType.Type;

import com.tinkerforge.BrickletAmbientLight;
import com.tinkerforge.IPConnection;

import controllers.persist.REMSPersist;
import controllers.sensors.implementation.AbstractSensorConfig;
import controllers.sensors.implementation.tinkerforge.devicelistener.AmbientListener;
import controllers.sensors.interfaces.Sensor;
import controllers.sensors.interfaces.SensorConfig;

public class TFConfig extends AbstractSensorConfig{
    
    private static final int PORT = 4223;
    private SensorType ambient;
    
    public TFConfig(REMSPersist persist) {
        super(persist);
        ambient = new SensorType(Type.AMBIENT, "LUX").save();
    }
    

    
    public ArrayList<Sensor> getSensors() {
     
        ArrayList<Sensor> sensors = new ArrayList<Sensor>();
        
        // All Sensors on Host 192.168.1.77;
        String host1 = "192.168.1.77";
        IPConnection ipcon1 = new IPConnection();
        String sensorUID = "8GL";
        BrickletAmbientLight ambientLight = new BrickletAmbientLight(sensorUID, ipcon1);
        ambientLight.addIlluminanceListener(new AmbientListener(persist, sensorUID, ambient));
        Sensor s1 = new TFSensor(ambientLight, ipcon1, host1, PORT);
        
        sensors.add(s1);

        return sensors;
    }
    
}
